package com.example.day16.ex07;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeSet;

public class PokerDemo02 {
    public static void main(String[] args) {
        HashMap<Integer,String>hm=new HashMap<>();
        ArrayList<Integer>array=new ArrayList<>();
        String []colors={"♦","♣","♥","♠"};
        String []numbers={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
        int index=0;
        for (String number:numbers){
            for (String color:colors){
                hm.put(index,color+number);
                array.add(index);
                index++;
            }
        }
        hm.put(index,"小王");
        array.add(index);
        index++;
        hm.put(index+1,"大王");
        array.add(index);
        Collections.shuffle(array);
        TreeSet<Integer>zhang=new TreeSet<>();
        TreeSet<Integer>li=new TreeSet<>();
        TreeSet<Integer>wang=new TreeSet<>();
        TreeSet<Integer>dp=new TreeSet<>();
        for (int i = 0; i < array.size(); i++){
            int x=array.get(i);
            if (i>=array.size()-3){
                dp.add(x);
            }else if(i%3==0){
                zhang.add(x);
            }else if(i%3==1){
                li.add(x);
            }else if(i%3==2){
                wang.add(x);
            }
        }
        lookPoker("张三",zhang,hm);
        lookPoker("李四",li,hm);
        lookPoker("王五",wang,hm);
        lookPoker("底牌",dp,hm);
    }
    public static void lookPoker(String name,TreeSet<Integer>ts,HashMap<Integer,String>hm){
        System.out.print(name+"的牌是：");
        for (Integer key:ts){
            String poker=hm.get(key);
            System.out.print(poker+" ");
        }
        System.out.println();
    }
}
